package com.ypj.indusynergyems.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ypj.indusynergyems.dao.entity.GoodsEntity;
import com.ypj.indusynergyems.dao.mapper.GoodsMapper;
import com.ypj.indusynergyems.service.IGoodsService;
import com.ypj.indusynergyems.service.MallSearchService;
import com.ypj.indusynergyems.web.SearchParam;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

@Service
@RequiredArgsConstructor
public class MallSearchServiceImpl implements MallSearchService {

    private final GoodsMapper goodsMapper;
    @Override
    public List<GoodsEntity> search(Integer catalog3Id,String keyword) {
        if (keyword != null){
            //写一个模糊查询的方法元素为
            return goodsMapper.selectList(Wrappers.<GoodsEntity>lambdaQuery().like(GoodsEntity::getGodsName,keyword));
        }else if(catalog3Id!=0){
            return goodsMapper.selectList(Wrappers.<GoodsEntity>lambdaQuery().eq(GoodsEntity::getPmsId,catalog3Id));
        }else {
            return goodsMapper.selectList(Wrappers.<GoodsEntity>lambdaQuery());
        }
    }
}
